package com.yangfei.SportAssistant.ui;

import com.yangfei.SportAssistant.R;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TableLayout;
import android.widget.TextView;

public class InfoCtrlGroup
{
	public TableLayout infoLayoutGroup;
	public TextView infoText;
	public TextView infoTextTitleGroup;
	public TextView infoTextUnitGroup;
	
	public int mButtonResId;
	public int mtextTitleResId;
	public int mtextUnitResId;

	public EActivityStats eStats = EActivityStats.eNone;

	Activity mParent = null;
	boolean metricUnits = true;

	public InfoCtrlGroup(Activity parent)
	{
		mParent = parent;
	}

	public void initFromRes(int ButtonResId, int textTitleResId)
	{
		infoTextTitleGroup = (TextView) mParent.findViewById(textTitleResId);
		infoText = (TextView) mParent.findViewById(ButtonResId);
		//infoTextUnitGroup = (TextView) mParent.findViewById(textUnitResId);
		
		mButtonResId = ButtonResId;
		mtextTitleResId = textTitleResId;
		//mtextUnitResId = textUnitResId;
	}

	public void SetStats(EActivityStats aStats)
	{
		eStats = aStats;
	}

	public EActivityStats GetStats()
	{
		return eStats;
	}

	private void setViewSize(View aview, int width, int height)
	{
		ViewGroup.LayoutParams linearParams = aview.getLayoutParams();
		linearParams.width = width;
		linearParams.height = height;

		aview.setLayoutParams(linearParams);
	}

	public static void SetButtonInfoType(InfoCtrlGroup aCtrl, EActivityStats eStats, boolean aMetricUnits)
	{
		if( aCtrl == null)
			return;
		aCtrl.SetStats(eStats);
		switch (eStats)
		{
			case eStartTime:
			case eMovingTime:
			case eAvgMovingSpeed:
			case eMaxSpeed:
			case eMinElevation:
			case eMaxElevation:
			case eMinGrade:
			case eMaxGrade:
			{
				break;
			}

			case eSpeed:
			{
				aCtrl.infoTextTitleGroup.setText(R.string.stat_speed);
				break;
			}
			case eAvgSpeed:
			{
				aCtrl.infoTextTitleGroup.setText(R.string.stat_average_speed);
				break;
			}
			case eTotalTime:
			{
				aCtrl.infoTextTitleGroup.setText(R.string.stat_total_time);
				break;
			}
			case eDistance:
			{
				aCtrl.infoTextTitleGroup.setText(R.string.stat_total_distance);
				break;
			}
			case eElevation:
			{
				aCtrl.infoTextTitleGroup.setText(R.string.stat_elevation);
				break;
			}
			case eElevationGain:
			{
				aCtrl.infoTextTitleGroup.setText(R.string.stat_elevation_gain);
				break;
			}
		}
	}

};